//
//  InquiryMain_VC_WX.m
//  ZITHER
//
//  Created by weixin on 2019/3/13.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "InquiryMain_VC_WX.h"
#import "InquiryMain_Title_view_WX.h"
#import "InquiryMain_TitleSelectMore_View_WX.h"
#import "InquiryMain_HotGoodsList_Tbv_WX.h"

@interface InquiryMain_VC_WX ()

@property (nonatomic,strong)InquiryMain_Title_view_WX * TtitleView;

@property (nonatomic,strong)InquiryMain_TitleSelectMore_View_WX * moreView;

@property (nonatomic,strong)InquiryMain_HotGoodsList_Tbv_WX * TB;



@end

@implementation InquiryMain_VC_WX

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self setNav];
    
    //    [self loaddata];
    
    [self setUI];
    
    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
        self.view.backgroundColor = Main_Token_Model_MANAGER.backgroundColor ;
    }
    
}

-(void)setNav{
    
    [self.baseNavigationView setHiddenNav:YES VC:self];
    
}

-(void)setUI{
    
    
    self.view.backgroundColor = HexColor(0xf5f5f5);
    
    BaseView *bgView = [[BaseView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
        bgView.backgroundColor = Main_Token_Model_MANAGER.backgroundColor ;
    }else{
        bgView.backgroundColor = [UIColor whiteColor];
        
    }
    [self.view addSubview:bgView];
     
    [self.view addSubview:self.TB];
    
    [self.view addSubview:self.TtitleView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.TtitleView.mas_bottom).offset(0);
    }];

    [self.TtitleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(kStatusBarHeight);

//        make.bottom.equalTo(self.TtitleView.mas_bottom).offset(0);
    }];
    [self.TB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.view).offset(-49-kBottomSafeHeight);
        make.top.equalTo(self.TtitleView.mas_bottom).offset(0);
    }];
}

- (InquiryMain_Title_view_WX *)TtitleView{
    if (!_TtitleView) {
        _TtitleView = [[InquiryMain_Title_view_WX alloc]initWithFrame:CGRectMake(0,kStatusBarHeight, SCREEN_WIDTH, 88 )];
        @weakify(self);
        
        [[_TtitleView.btn3 addTag]subscribeNext:^(id  _Nullable x) {
            @strongify(self);
//            self.TtitleView.btn3.selected = !self.TtitleView.btn3.selected;
            [self.moreView show];
            [self.moreView.TitleSelectMoreBtnView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.TtitleView.btn3).offset(0);
                make.top.equalTo(self.TtitleView.btn3.mas_bottom).offset(10);
                make.width.mas_equalTo(100);
                make.height.mas_equalTo(151);
            }];
            
            if (self.TtitleView.btn3.selected) {
//                [self.moreView show];
            }else{
//                [self.moreView hide];
            }
        }];
    }
    return _TtitleView;
}


-(InquiryMain_TitleSelectMore_View_WX *)moreView{
    if (!_moreView) {
        _moreView = [[InquiryMain_TitleSelectMore_View_WX alloc]initWithFrame:CGRectMake(0,0, kScreenW, kScreenH)];
        @weakify(self);
        [_moreView setBlock:^(NSInteger index, NSArray * _Nonnull arrTitle, NSArray * _Nonnull arrImg) {
           
            @strongify(self);
            [self.TtitleView.btn3 setTitle:arrTitle[index-100] forState:UIControlStateNormal];
//            [self.TtitleView.btn3 setTitle:arrTitle[index-100] forState:UIControlStateSelected];
            [self.TtitleView.btn3 setImage:[UIImage imageNamed:arrImg[index-100]] forState:UIControlStateNormal];
//            [self.TtitleView.btn3 setImage:arrImg[index-100] forState:UIControlStateSelected];
            self.TB.type = index - 100;

        }];
    
        
    }
    return _moreView;
}


- (InquiryMain_HotGoodsList_Tbv_WX *)TB{
    if (!_TB) {
        _TB = [[InquiryMain_HotGoodsList_Tbv_WX alloc]initializeFrame:CGRectMake(0, 0, 1, 1) isMj:1 isEstimatedRowHeight:YES addRegisterNib:@[@"InquiryMain_HotGoodsList_Cell_WX"]];
        
    }
    return _TB;
}

@end
